<?php

namespace App\Handler\Admin\System;

if (!defined('IN_PX'))
    exit;

use Phoenix\Routing\IHttpHandler;
use Phoenix\Support\MsgHelper;

class SaveForm implements IHttpHandler {

    private function __Handler() {}

    private function __Inject($db, $session) {}

    public function processRequest(Array & $context)
    {
        if (is_array($_POST) && !empty($_POST)) {
            $data = $_POST;
            $_r = $this->db->table('`#@__@form`')
                ->row(array(
                    '`company_name`' => '?',
                    '`address`' => '?',
                    '`people`' => '?',
                    '`mail`' => '?',
                    '`mobile`' => '?',
                    '`fax`' => '?',
                    '`content`' => '?',
                    '`add_time`' => '?'
                ))
                ->bind(array(
                    $data['company_name'],
                    $data['address'],
                    $data['people'],
                    $data['mail'],
                    $data['mobile'],
                    $data['fax'],
                    $data['content'],
                    time()
                ))
                ->save();
            if ($_r) {
                echo(MsgHelper::json('SUCCESS',$_r));
            } else {
                echo(MsgHelper::json('ERROR'));
            }
        } else {
            echo(MsgHelper::json('ERROR'));
        }
    }
}
